var t = getApp();

Page({
    data: {
        textShow: !1,
        phoneShow: !1,
        priceShow: !1,
        content: "",
        textId: "",
        needUpdate: !1
    },
    onLoad: function(t) {
        this.loadData();
    },
    loadData: function() {
        var a = this;
        t.network.post({
            url: t.url.getScheduleCardInfo,
            params: {},
            before: function() {
                wx.showNavigationBarLoading();
            },
            success: function(e) {
                1 == e.data.result ? a.setData({
                    textShow: e.data.data.textShow,
                    phoneShow: e.data.data.phoneShow,
                    priceShow: e.data.data.priceShow,
                    content: e.data.data.content
                }) : t.util.showToast(e.data.message);
            },
            fail: function() {
                t.util.showToast("获取设置失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading();
            }
        });
    },
    changeTextSwitch: function(t) {
        this.setData({
            textShow: t.detail.value ? 1 : 0
        }), this.updateChangeSwitch();
    },
    changePhoneSwitch: function(t) {
        this.setData({
            phoneShow: t.detail.value ? 1 : 0
        }), this.updateChangeSwitch();
    },
    changePriceSwitch: function(t) {
        this.setData({
            priceShow: t.detail.value ? 1 : 0
        }), this.updateChangeSwitch();
    },
    clickChangeText: function(t) {
        wx.navigateTo({
            url: "/pages/schedule/scheduleCardText/scheduleCardText"
        });
    },
    clickDiy: function(t) {
        wx.navigateTo({
            url: "/pages/schedule/scheduleCardEditText/scheduleCardEditText"
        });
    },
    updateChangeSwitch: function(a) {
        var e = this;
        this.setData({
            needUpdate: !1
        }), t.network.post({
            url: t.url.setScheduleCardInfo,
            params: {
                textShow: e.data.textShow,
                phoneShow: e.data.phoneShow,
                priceShow: e.data.priceShow,
                content: e.data.content,
                textId: e.data.textId
            },
            before: function() {
                wx.showLoading({
                    title: "正在修改"
                }), wx.showNavigationBarLoading();
            },
            success: function(a) {
                if (wx.hideLoading(), 1 == a.data.result) {
                    var e = getCurrentPages();
                    e[e.length - 2].setData({
                        needUpdate: !0
                    });
                } else t.util.showToast(a.data.message);
            },
            fail: function() {
                wx.hideLoading(), t.util.showToast("获取设置失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading();
            }
        });
    },
    onReady: function() {},
    onShow: function() {
        this.data.needUpdate && this.updateChangeSwitch();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});